package com.lhy.admin.model.extend;

import com.lhy.admin.common.treeable.Treeable;
import com.lhy.admin.model.FileMapping;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class FileMappingTree extends FileMapping implements Treeable {

    private List<Treeable> children = new ArrayList<>();

    public FileMappingTree(FileMapping fileMapping) {
        BeanUtils.copyProperties(fileMapping,this);
    }

    @Override
    public List<Treeable> getChildren() {
        return children;
    }

    @Override
    public Treenode asTreenode() {
        Treenode node = new Treenode();
        node.id = getId();
        node.pid = getParent();
        node.text = getName();
        node.type = getParent() == 0 ? "#" : "fileMapping";
        return node;
    }
}
